//
//  ActivityFirstCell.m
//  A段项目
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ActivityFirstCell.h"
#import "Model.h"
#import <UIImageView+WebCache.h>

#define  WIDTH  [UIScreen mainScreen].bounds.size.width

@interface ActivityFirstCell ()

@property (nonatomic, retain) UIImageView *imageForUp;
@property (nonatomic, retain) UILabel *labelOfDown;

@end

@implementation ActivityFirstCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.imageForUp = [[UIImageView alloc] init];
        self.labelOfDown = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.imageForUp];
        [self.contentView addSubview: self.labelOfDown];
        
        
        [_imageForUp release];
        [_labelOfDown release];
        
    }
    
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    self.imageForUp.frame = CGRectMake(5, 0, self.frame.size.width - 10, 200);
    self.labelOfDown.frame = CGRectMake(10, 200, self.frame.size.width - 20, [[ActivityFirstCell class]heightForText:self.labelOfDown.text]);
    
}

- (void)passedInfo:(Model *)model {
    
    self.labelOfDown.text =model.summary;
    self.labelOfDown.numberOfLines = 0;
    [self.imageForUp sd_setImageWithURL:[NSURL URLWithString:model.logoUrl]];
    
    self.labelOfDown.font = [UIFont systemFontOfSize:15];
    
}


+ (CGFloat)heightForText:(NSString *)str {
    
    
      CGRect rect = [str boundingRectWithSize:CGSizeMake(WIDTH - 20, 0) options:1 attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
    
    return rect.size.height;
    
}

+(CGFloat)heightForCell:(Model *)model {
    
 
    
    CGFloat height = [ActivityFirstCell heightForText:model.summary];
    
    return height + 200;
    
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
